package com.junzerg.tooltip.controller;

import com.alibaba.fastjson.JSONObject;
import com.junzerg.tooltip.component.ConvComponent;
import com.junzerg.tooltip.controller.request.ConvRequest;
import com.junzerg.tooltip.controller.response.ConvResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author pengjz <br>
 * @version 1.0 <br>
 * @description ConvController <br>
 * @date 2022/4/7 13:40 <br>
 */
@RestController
@RequestMapping(value = "/conv")
@Slf4j
@ResponseBody
public class ConvController extends BaseController {

    @Resource
    ConvComponent component;

    @PostMapping("/search")
    public Object getTranslate(
            @RequestBody ConvRequest request
    ) {
        log.info("[getTranslate] request: {}", JSONObject.toJSONString(request));
        return success(component.searchByAddress(request));
    }


    @GetMapping("/announcement")
    public Object getConvAnnouncement() {
        log.info("[getConvAnnouncement]");
        return success(component.getConvAnnouncement());
    }

    @GetMapping("/inputTips")
    public Object getInputTips(
            @RequestParam String q
    ) {
        return success(component.getInputTips(q));
    }


}
